home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / tracertest.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  1.8 KB  |  65 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright Â© 1992 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Originator: Kent Sandvik
  5.   Date: Friday, July 10, 1992 10:14:13
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TTracer is an example of a stack/heap based tracing class, which could be
  9.   used for tracing memory leaks and keeping track of created objects
  10.   TestTracer.cp contains test code for testing the TTracer class.
  11.   _________________________________________________________________________________________________________ */
  12.  
  13.  
  14. // Include files
  15. #ifndef _TRACER_
  16. #include "Tracer.h"
  17. #endif
  18.  
  19. // Function used for testing TTracer.
  20. void InvertPermutation(int* perm,
  21.                        int* inv,
  22.                        int max)
  23. {
  24.     TTracer autoTracer("InvertPermutation function", TRACEPOINT);
  25.  
  26.     if (perm && (new TTracer("temp", TRACEPOINT))// show TTracer in action
  27.         && inv && (new TTracer("temp2", TRACEPOINT))// these two are never destructed =
  28.         && (max > 0))                            // memory leak!
  29.     {
  30.         TTracer otherTracer("otherTracer", TRACEPOINT);
  31.  
  32.         for (int i = 0; i < max; i++)
  33.         {
  34.             TTracer thirdTracer("iterationTracing...", TRACEPOINT);
  35.             inv[perm[i]] = i;
  36.         }
  37.     }
  38. }
  39.  
  40.  
  41. // Test code itself.
  42. void main(void)
  43. {
  44.     cout << "The TTracer test is starting…\n";
  45.  
  46.     // Array declarations used in the test
  47.     int perm[] = {
  48.                   1, 2, 3, 6, 7};
  49.     int max = 5;
  50.  
  51.     int* inv = new
  52.               int[max];
  53.     InvertPermutation(&perm[0], inv, max);
  54.  
  55.     cout << "The TTracer test ended!\n";
  56. }
  57.  
  58. // _________________________________________________________________________________________________________ //
  59.  
  60.  
  61. /*    Change History (most recent last):
  62.   No        Init.    Date        Comment
  63.   1            khs        7/10/92        New file
  64. */
  65.